import { TweenExt } from "../Tool/TweenExt";


export default class MyViewBase extends Laya.View
{
    protected m_root:Laya.Image=null;
    protected m_showAmTime=200;
    protected m_ease:Function=Laya.Ease.linearNone;
    constructor()
    {
        super();
        Laya.stage.addChild(this);
        this.m_root=this.getChildByName("Root") as Laya.Image;
        this.m_root.mouseThrough=true;
        this.InitView();
        this.visible=false;
    }

    protected InitView(){
    
    }

        
    public  OnEnter(param?:any)
    {
        this.visible=true;
        this.ShowScalAm();
    }

    public  OnPause()
    {
        
    }

    public  OnExit()
    {
        this.HideScalAm();
    }

    public  OnResume()
    {
        this.visible=true;
    }

    protected ShowScalAm()
    {
        this.mouseEnabled=false;
        this.m_root.width=Laya.stage.width;
        this.m_root.height=Laya.stage.height;
        this.m_root.centerX=0;
        this.m_root.centerY=0;
        this.m_root.scaleX=0;
        this.m_root.scaleY=0;
        TweenExt.TweenUIScal(this.m_root,1,this.m_showAmTime,this.ShowEnd.bind(this),this.m_ease);
    }

    protected HideScalAm()
    {
        this.mouseEnabled=false;
        TweenExt.TweenUIScal(this.m_root,0,this.m_showAmTime,this.HideEnd.bind(this),this.m_ease);
    }


    protected ShowPosAm()
    {
        this.mouseEnabled=false;
        this.m_root.x=this.width*2;
        this.m_root.centerY=0;
        TweenExt.TweenUIPosX(this.m_root,this.width/2,this.m_showAmTime,this.ShowEnd.bind(this),this.m_ease);
    }

    protected HidePosAm()
    {
        this.mouseEnabled=false;
        TweenExt.TweenUIPosX(this.m_root,this.width*2,this.m_showAmTime,this.HideEnd.bind(this),this.m_ease);
    }





    protected ShowEnd()
    {
        this.mouseEnabled=true;
    }

    protected HideEnd()
    { 
        this.mouseEnabled=true;
        this.visible=false;
      
    }

    protected ShowBtnClickAm(btn:Laya.UIComponent,time=500,scal=1.2)
    {
        TweenExt.TweenUINodeScalCycle(btn,time,scal);
    }
}
    
 

